package game.particle;

import engine.j2d.Color;
import engine.j2d.Texture;
import engine.math.Vector2f;
import engine.system.ToolKit;

public class ParticleSystem
{
	protected Particle particles[];
	public boolean wasPlayed= false;
	protected final double pi=Math.PI;
	protected  float fade;
	protected float xs;
	protected float ys;
	protected float ang;
	Texture texture;
	
	public ParticleSystem(String path,int num, float life,
			Vector2f partPos, Vector2f partSize, Vector2f velo,Color color)
	{
		texture = ToolKit.getTexture(path);
		particles = new Particle[num];
		for (int i = 0; i < particles.length; ++i) {
			particles[i] = new Particle(partPos, partSize, velo, color, life);
		}
	}

	public void render(float death)
	{
		texture.bind();
		for (Particle par : particles) {
			par.render();
			par.move();
			par.setDLife(death);
			if (par.getLife() < 0.05f) {
				wasPlayed = true;
			}
		}
	}
	public void render()
	{
		texture.bind();
		for (Particle par : particles) {
			par.render();
			par.move();
			if (par.getLife() < 0.05f)
				wasPlayed = true;
		}
	}
}
